package cn.fl.risknew.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.DecimalUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.customer.service.ICstNpBscInfoService;
import cn.fl.customer.vo.CstBscInfoVO;
import cn.fl.customer.vo.CstNpBscInfoVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.risknew.condition.RskCommRecQueryCondition;
import cn.fl.risknew.constant.RiskConstant;
import cn.fl.risknew.service.IRiskLevelService;
import cn.fl.risknew.service.IRskCommRecNewService;
import cn.fl.risknew.util.SpringWebSocketHandler;
import cn.fl.risknew.vo.CCardResult;
import cn.fl.risknew.vo.RskCommRecVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysUlFilesRecService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.customer.facade.customer.dto.CstContactInfoDTO;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @Description: 沟通记录表 控制层
 */
@Controller
@RequestMapping("/risknew/rskCommRecNew")
public class RskCommRecNewController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(RskCommRecNewController.class);

    /**
     * RskCommRec 服务层BEAN
     */
    @Autowired
    private IRskCommRecNewService rskCommRecNewService;
    /**
     * 客户 服务层BEAN
     */
    @Autowired
    private ICstBscInfoService cstBscInfoService;
    /**
     * 客户 服务层BEAN
     */
    @Autowired
    private ICstNpBscInfoService cstNpBscInfoService;

    /**
     * 数据字典服务
     */
    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

    /**
     * 附件服务
     */
    @Autowired
    private ISysUlFilesRecService sysUlFilesRecService;

    @Resource
    private IRiskLevelService riskLevelService;
    
    @Bean//这个注解会从Spring容器拿出Bean
    public SpringWebSocketHandler infoHandler() {
        return new SpringWebSocketHandler();
    }

    /*******************************
     * 到沟通记录管理页面
     *******************************/
    @RequestMapping(value = "/toMgrPage.do", method = {RequestMethod.GET})
    public ModelAndView toMgrPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "加载到沟通记录管理页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("risk/rskCommRec/rskCommRec");
        return mav;
    }

    /**
     * 到列表页面
     */
    @RequestMapping(value = "/toListPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "加载RskCommRec列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("risknew/rskCommRec/rskCommRecList");
        String cstId = request.getParameter("cstId");//客户ID
        String cstNm = request.getParameter("cstNm");//客户名称
        // 事业部
        /*List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
        mav.addObject("buOrgCdList", JSON.toJSONString(orgList));*/
        RskCommRecVO rskCommRecVO = new RskCommRecVO();
        rskCommRecVO.setCstId(Long.valueOf(cstId));
        rskCommRecVO.setCstNm(cstNm);

        //查询客户联系人信息
        List<Long> idList = new ArrayList<>(1);
        idList.add(rskCommRecVO.getCstId());
        List<CstContactInfoDTO> cstContactInfoDTOList = this.rskCommRecNewService.searchCstLkMan(idList);
        if (CollectionUtils.isNotEmpty(cstContactInfoDTOList)) {
            CstContactInfoDTO contactInfoDTO = cstContactInfoDTOList.get(0);
            rskCommRecVO.setLkPhone(contactInfoDTO.getMp1());//联系人电话
            rskCommRecVO.setLkMan(contactInfoDTO.getCstNm());//联系人名称
        }
        CstBscInfoVO cstBscInfoVO = cstBscInfoService.selectById(rskCommRecVO.getCstId());
        if (null != cstBscInfoVO) {
            rskCommRecVO.setPayTypCd(cstBscInfoVO.getPayTypCd());
            //rskCommRecVO.setCstTypCd(cstBscInfoVO.getCstTypCd());
            rskCommRecVO.setCstBscInfoVO(cstBscInfoVO);
            if(StringUtils.isNotEmpty(cstBscInfoVO.getCstTypCd()) && "1".equals(cstBscInfoVO.getCstTypCd())){//自然人
                CstNpBscInfoVO cstNpBscInfoVO = cstNpBscInfoService.selectById(cstBscInfoVO.getId());
                rskCommRecVO.setCstNpBscInfoVO(cstNpBscInfoVO);
            }
        }
        rskCommRecVO.setCollectTms(DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DDHHMM));
        rskCommRecVO.setCollectUsrId(CurrentThreadContext.getCurrentUserId());
        rskCommRecVO.setCollectUsrNm(CurrentThreadContext.getCurrentUserName());
        String ovdAmt=request.getParameter("ovdAmt");
        if(StringUtils.isNotBlank(ovdAmt)) {
        	ovdAmt="￥"+DecimalUtils.convertFenToYuan(Long.parseLong(ovdAmt)); 
        	mav.addObject("ovdAmt", ovdAmt);
        }
        mav.addObject("minOverdueDate", request.getParameter("minOverdueDate"));
        mav.addObject("rskCommRecVO", rskCommRecVO);
        mav.addObject("cstId", request.getParameter("cstId"));
        // TODO 查询贷前风险标记 接口还没提供
        String preLoanRskInfo = this.rskCommRecNewService.searchPreLoanRskInfo(cstBscInfoVO.getId());
        mav.addObject("preLoanRskInfo",preLoanRskInfo);
        //查询C卡数据  放入mav
        try {
            CCardResult cRiskLevel = riskLevelService.getCRiskLevel(Long.parseLong(request.getParameter("cstId")));
            mav.addObject("cRiskLevel",getCRiskLevel(cRiskLevel.getFinalRiskLevel()));
        } catch (Exception e) {
            //查询C卡数据失败
            logger.error("查询客户C卡数据异常 cstId={}",request.getParameter("cstId"));
        }
        mav.addObject("collectRiskLevel",getRiskLevel());
        this.prepare(request, mav);//数据字典
        return mav;
    }

    /**
     * 风险等级
     * @return
     */
    private List<KeyValueVO>  getRiskLevel(){
        List<KeyValueVO> list = new ArrayList<>();
        KeyValueVO hign = new KeyValueVO();
        hign.setKey("A");
        hign.setValue("高");
        list.add(hign);

        KeyValueVO middle = new KeyValueVO();
        middle.setKey("B");
        middle.setValue("中");
        list.add(middle);

        KeyValueVO low = new KeyValueVO();
        low.setKey("C");
        low.setValue("低");
        list.add(low);
        return list;
    }

    /**
     * C卡
     * @param risk
     * @return
     */
    private List<KeyValueVO> getCRiskLevel(String risk){
        List<KeyValueVO> list = new ArrayList<>();
        KeyValueVO vo = new KeyValueVO();
        vo.setKey(risk);
        if("A".equals(risk)){
            vo.setValue("高");
        }else if("B".equals(risk)){
            vo.setValue("中");
        }else if("C".equals(risk)){
            vo.setValue("低");
        }
        list.add(vo);
        return list;
    }


    /**
     * 沟通记录列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/toRecListPage.do", method = {RequestMethod.GET})
    public ModelAndView toRecListPage(HttpServletRequest request, HttpServletResponse response){
        BaseLogUtils.info(logger,"toRecListPage","加载沟通记录列表",CurrentThreadContext.getCurrentUserName());
        String buTypCd = request.getParameter("buTypCd");//沟通业务类型：1.逾期催收 2.租金提醒 3.续保提醒 4.起租提醒
        ModelAndView mav = new ModelAndView();
        mav.addObject("buTypCd",buTypCd);
        if(RiskConstant.CODE_BU_TYP_CD_1.equals(buTypCd)){
            mav.setViewName("risk/rskCommRec/rskCommRecList");
        }else if(RiskConstant.CODE_BU_TYP_CD_2.equals(buTypCd)){
            mav.setViewName("risk/rskCommRec/rskRentRecList");
        }else if(RiskConstant.CODE_BU_TYP_CD_4.equals(buTypCd)){
            mav.setViewName("risk/rskCommRec/rskRentRecList");
        }else{
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700);
        }
        // 事业部
        List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
        if (CollectionUtils.isNotEmpty(orgList)) {
            mav.addObject("buOrgCdList", JSON.toJSONString(orgList));
        }
        //沟通方式（催收方式）
        List<KeyValueVO> collectWayCdList = this.rskCommRecNewService.getCollectWayCdList();
        if (CollectionUtils.isNotEmpty(collectWayCdList)) {
            mav.addObject("collectWayCdList", JSON.toJSONString(collectWayCdList));
        }
        //外呼结果
        List<KeyValueVO> commStsCdList = this.rskCommRecNewService.getCommStsCdList();
        if (CollectionUtils.isNotEmpty(commStsCdList)) {
            mav.addObject("commStsCdList", JSON.toJSONString(commStsCdList));
        }

        return mav;
    }

    /**
     * 到新增页面
     */
    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toAddPage", "加载RskCommRec Add页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("risk/rskCommRec/rskCommRecModify");
        //this.prepare(request,mav);
        return mav;
    }

    /**
     * 到修改页面（查看）
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toModifyPage", "加载RskCommRec Modify页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("risknew/rskCommRec/rskCommRecModify");
        //this.prepare(request,mav);

        String id = request.getParameter("id");
        RskCommRecVO rskCommRecVO = this.rskCommRecNewService.selectById(Long.valueOf(id));
        CstBscInfoVO cstBscInfoVO = cstBscInfoService.selectById(rskCommRecVO.getCstId());
        if (null != cstBscInfoVO) {
            rskCommRecVO.setPayTypCd(cstBscInfoVO.getPayTypCd());
        }
        //拼接数据
        setDictionaryForModify(rskCommRecVO);
        mav.addObject("rskCommRecVO", rskCommRecVO);
        return mav;
    }

    //加载数据字典数据、传值等 ？
    public void prepare(HttpServletRequest request, ModelAndView mav) {
        // 地址真实性
        List<KeyValueVO> isRealAdressList = this.sysDictionaryApiService.getKvList("RSK0015", CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if(CollectionUtils.isNotEmpty(isRealAdressList)){
            mav.addObject("isRealAdressList", JSON.toJSONString(isRealAdressList));
        }
        // 信函发送方式
        List<KeyValueVO> letterSendWayList = this.sysDictionaryApiService.getKvList("RSK0035", CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if(CollectionUtils.isNotEmpty(letterSendWayList)){
            mav.addObject("letterSendWayList", JSON.toJSONString(letterSendWayList));
        }
        // 信函发送结果
        List<KeyValueVO> letterSendResList = this.sysDictionaryApiService.getKvList("RSK0034", CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if(CollectionUtils.isNotEmpty(letterSendResList)){
            mav.addObject("letterSendResList", JSON.toJSONString(letterSendResList));
        }

        //催收方式
        List<KeyValueVO> collectWayCdList = this.rskCommRecNewService.getCollectWayCdList();
        if (CollectionUtils.isNotEmpty(collectWayCdList)) {
            mav.addObject("collectWayCdList", JSON.toJSONString(collectWayCdList));
        }
        //风险等级 KeyValueVO
        List<KeyValueVO> payWnCdList = this.sysDictionaryApiService.getKvList(RiskConstant.CODE_PAY_WN_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if (CollectionUtils.isNotEmpty(payWnCdList)) {
            BaseLogUtils.info(logger, "prepare", "还款意愿：", JSON.toJSONString(payWnCdList));
            mav.addObject("payWnCdList", JSON.toJSONString(payWnCdList));
        }
        //还款意愿SysDictionaryDTO
        List<SysDictionaryDTO> payWnCdDTOS = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),RiskConstant.CODE_PAY_WN_CD);
        if (CollectionUtils.isNotEmpty(payWnCdList)) {
            mav.addObject("payWnCdDTOS", JSON.toJSONString(payWnCdDTOS));
        }
        
        //逾期原因 KeyValueVO
        List<KeyValueVO> ovdReasonCdList = this.rskCommRecNewService.getOvdReasonCdList();
        if (CollectionUtils.isNotEmpty(ovdReasonCdList)) {
            mav.addObject("ovdReasonCdList", JSON.toJSONString(ovdReasonCdList));
        }
        //逾期原因 SysDictionaryDTO
        List<SysDictionaryDTO> ovdReasonDTOS = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),RiskConstant.CODE_OVD_REASON_CD);
        if (CollectionUtils.isNotEmpty(ovdReasonDTOS)) {
            mav.addObject("ovdReasonDTOS", JSON.toJSONString(ovdReasonDTOS));
        }
        // 渠道参与者
        List<SysDictionaryDTO> participantList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),"RSK0037");
        if (CollectionUtils.isNotEmpty(participantList)) {
            mav.addObject("participantList", JSON.toJSONString(participantList));
        }
        //逾期催收结果
        List<KeyValueVO> collectRstCdList = this.rskCommRecNewService.getCollectRstCdList();
        if (CollectionUtils.isNotEmpty(collectRstCdList)) {
            mav.addObject("collectRstCdList", JSON.toJSONString(collectRstCdList));
        }
        //还款方式
        List<KeyValueVO> payTypCdList = this.rskCommRecNewService.getPayTypCdList();
        if (CollectionUtils.isNotEmpty(payTypCdList)) {
            mav.addObject("payTypCdList", JSON.toJSONString(payTypCdList));
        }
        //接通情况
        List<KeyValueVO> cntStsCdList = sysDictionaryApiService.getKvList(RiskConstant.CODE_CNT_STS_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if (CollectionUtils.isNotEmpty(cntStsCdList)) {
            mav.addObject("cntStsCdList", JSON.toJSONString(cntStsCdList));
        }
        //面谈人类型
        List<KeyValueVO> invTypCdList = sysDictionaryApiService.getKvList(RiskConstant.CODE_INV_TYP_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if (CollectionUtils.isNotEmpty(invTypCdList)) {
            mav.addObject("invTypCdList", JSON.toJSONString(invTypCdList));
        }
        //信函类型
        List<KeyValueVO> letterTypCdList = sysDictionaryApiService.getKvList(RiskConstant.CODE_LETTER_TYP_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if (CollectionUtils.isNotEmpty(letterTypCdList)) {
            mav.addObject("letterTypCdList", JSON.toJSONString(letterTypCdList));
        }
        //外访结果
        List<KeyValueVO> visitRstCdList = sysDictionaryApiService.getKvList("RSK0036", CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if (CollectionUtils.isNotEmpty(visitRstCdList)) {
            mav.addObject("visitRstCdList", JSON.toJSONString(visitRstCdList));
        }
        // 客户反馈受新型肺炎影响
        List<KeyValueVO> cstFeedbackCdList = sysDictionaryApiService.getKvList(RiskConstant.CST_FEEDBACK_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if (CollectionUtils.isNotEmpty(cstFeedbackCdList)) {
            mav.addObject("cstFeedbackCdList", cstFeedbackCdList);
        }
        // 公司审批受新型肺炎影响
        List<KeyValueVO> compFeedbackCdList = sysDictionaryApiService.getKvList(RiskConstant.COMP_FEEDBACK_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        if (CollectionUtils.isNotEmpty(compFeedbackCdList)) {
            mav.addObject("compFeedbackCdList", compFeedbackCdList);
        }
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initRskCommRecList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        RskCommRecQueryCondition qc = new RskCommRecQueryCondition();
        String cstId = request.getParameter("cstId");
        String cstNm = request.getParameter("cstNm");
        String collectUsrNm = request.getParameter("collectUsrNm");
        String buTypCd = request.getParameter("buTypCd");
        String buOrgCd = request.getParameter("buOrgCd");
        String startCollectTm = request.getParameter("startCollectTm");
        String endCollectTm = request.getParameter("endCollectTm");
        String bizNo = request.getParameter("bizNo");
        String collectWayCd = request.getParameter("collectWayCd");
        String commStsCd = request.getParameter("commStsCd");

        if (StringUtils.isNotBlank(buOrgCd)) {
            qc.setBuOrgCd(buOrgCd);
        }
        if (StringUtils.isNotBlank(startCollectTm)) {
            qc.setStartCollectTm(startCollectTm);
        }
        if (StringUtils.isNotBlank(endCollectTm)) {
            qc.setEndCollectTm(endCollectTm);
        }
        if (StringUtils.isNotEmpty(cstId)) {
            qc.setCstId(Long.valueOf(cstId));
        }
        if (StringUtils.isNotBlank(cstNm)) {
            qc.setCstNm(cstNm);
        }
        if (StringUtils.isNotBlank(collectUsrNm)) {
            qc.setCollectUsrNm(collectUsrNm);
        }
        if (StringUtils.isNotBlank(buTypCd)) {
            qc.setBuTypCd(buTypCd);
        }
        if (StringUtils.isNotBlank(bizNo)) {
            qc.setBizNo(bizNo);
        }
        if(StringUtils.isNotBlank(collectWayCd)){
            qc.setCollectWayCd(collectWayCd);
        }
        if(StringUtils.isNotBlank(commStsCd)){
        	qc.setCommStsCd(commStsCd);
        }
        qc.setRoleId(CurrentThreadContext.getCurrentRoleId());
        page.setCondition(qc);

        BaseLogUtils.info(logger, "initRskCommRecList", "初始化RskCommRec列表页面数据.DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
        Pager pager = this.rskCommRecNewService.searchListPage(page);
        List<RskCommRecVO> list = (List<RskCommRecVO>) pager.getResultList();
        ListPageVO<RskCommRecVO> listPage = new ListPageVO<RskCommRecVO>(list, pager.getTotalCount());
        return listPage;
    }

    /**
     * 删除数据
     */
    @RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removeRskCommRecByIds(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String ids = request.getParameter("ids");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
        if (StringUtils.isEmpty(ids)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "removeRskCommRecByIds", "删除RskCommRec数据,主键参数为空!", CurrentThreadContext.getCurrentUserName());
            return result;
        }

        List<Long> idsList = new ArrayList<Long>();
        JSONArray idsArray = JSONArray.fromObject(ids);
        for (Object object : idsArray) {
            idsList.add(Long.valueOf(object.toString()));
        }

        try {
            boolean success = this.rskCommRecNewService.removeByIds(idsList);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
                BaseLogUtils.info(logger, "removeRskCommRecByIds", "删除RskCommRec数据失败,ID:" + idsList.toString(), CurrentThreadContext.getCurrentUserName());
            }
            BaseLogUtils.info(logger, "removeRskCommRecByIds", "删除RskCommRec数据成功,ID:" + idsList.toString(), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "removeRskCommRecByIds", "删除RskCommRec数据失败,ID:" + idsList.toString() + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "removeRskCommRecByIds", "删除RskCommRec数据失败,系统错误.ID:" + idsList.toString() + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 得到一条记录
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getRskCommRecById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "getRskCommRecById", "获取RskCommRec数据,主键参数为空.", CurrentThreadContext.getCurrentUserName());
            return result;
        }

        try {
            RskCommRecVO vo = this.rskCommRecNewService.selectById(Long.valueOf(id));
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
                BaseLogUtils.info(logger, "getRskCommRecById", "获取RskCommRec数据不存在,ID:" + id, CurrentThreadContext.getCurrentUserName());
            }
            result.setData(vo);
            BaseLogUtils.info(logger, "getRskCommRecById", "获取RskCommRec数据成功,ID:" + id, CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "getRskCommRecById", "获取RskCommRec数据失败,ID:" + id + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getRskCommRecById", "获取RskCommRec数据失败,系统错误.ID:" + id + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object addRskCommRec(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        RskCommRecVO entity = null;//获取参数
        try {
            entity = this.getRequestParamForRskCommRec(request);//获取参数
            Long id = this.rskCommRecNewService.add(entity);
            result.setData(id);
            //上传附件
            uploadAttchment(request, result, id);
            BaseLogUtils.info(logger, "addRskCommRec", "新增RskCommRec数据成功,ID:" + id + ".DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.info(logger, "addRskCommRec", "新增RskCommRec数据失败.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.error(logger, "addRskCommRec", "新增RskCommRec数据失败,系统错误.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/modify.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modifyRskCommRec(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
        RskCommRecVO entity = null;
        try {
            entity = this.getRequestParamForRskCommRec(request);
            if (entity.getId() == null) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
                BaseLogUtils.info(logger, "modifyRskCommRec", "修改RskCommRec信息,主键参数为空！.", CurrentThreadContext.getCurrentUserName());
                return result;
            }

            boolean success = this.rskCommRecNewService.modify(entity);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
                BaseLogUtils.info(logger, "modifyRskCommRec", "修改RskCommRec数据失败.DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
                return result;
            }
            BaseLogUtils.info(logger, "modifyRskCommRec", "修改RskCommRec数据成功.DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.info(logger, "modifyRskCommRec", "修改RskCommRec数据失败.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.error(logger, "modifyRskCommRec", "修改RskCommRec数据失败,系统错误.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 获取请求参数
     *
     * @param request 请求
     * @return
     */
    private RskCommRecVO getRequestParamForRskCommRec(HttpServletRequest request) throws BaseException {
        //获取参数
        String id = request.getParameter("id");//主键
        String cstId = request.getParameter("winCstId");//客户ID winCstId
        String cstNm = request.getParameter("winCstNm");//客户名称
        String lkMan = request.getParameter("winlkMan");//联系人
        String lkPhone = request.getParameter("winLkPhone");//联系电话
        String lkAddr = request.getParameter("winLkAddr");//联系地址
        String collectWayCd = request.getParameter("winCollectWayCd");//催收方式
        String payWnCd = request.getParameter("winPayWnCd");//还款意愿 RSK0010
        String ovdReasonCd = request.getParameter("winOvdReasonCd");//欠款原因
        String collectUsrId = request.getParameter("winCollectUsrId");//催收员ID
        String collectUsrNm = request.getParameter("winCollectUsrNm");//催收人员名称
        String isConnect = request.getParameter("winIsConnect");//电话催收是否接通 0 否  1 是
        String letterTypCd = request.getParameter("winLetterTypCd");//信函类型 RSK0014
        String visitRstCd = request.getParameter("winVisitRstCd");//外访结果 RSK0015
        String rlNm = request.getParameter("winRlNm");//关联人姓名（面谈人）
        String rlTypCd = request.getParameter("winRlTypCd");//与客户的关系
        String rlMp = request.getParameter("winRlMp");//关联人电话
        String collectRstCd = request.getParameter("winCollectRstCd");//催收结果
        String appoDt = request.getParameter("winAppoDt");//承诺时间/再联系时间/核实时间
        String invTypCd = request.getParameter("winInvTypCd");//面谈人类型 RSK0016
        String cntStsCd = request.getParameter("winCntStsCd");//电话催收接通情况 RSK0013
        String collectRem = request.getParameter("winCollectRem");//催收记录(催收详情)
        String lKTypCd = request.getParameter("lKTypCd");//联系人与客户关系
        // 客户反馈受新型肺炎影响
        String cstFeedbackCd = request.getParameter("cstFeedbackCd");
        // 公司审批受新型肺炎影响
        String compFeedbackCd = request.getParameter("compFeedbackCd");
        String preLoanRskInfo = request.getParameter("preLoanRskInfo");
        String letterSendRes = request.getParameter("letterSendRes");
        String letterSendWay = request.getParameter("letterSendWay");
        String expressNo = request.getParameter("expressNo");
        String realAdress = request.getParameter("realAdress");
        String isRealAdress = request.getParameter("isRealAdress");
        String participant = request.getParameter("participantDiv");

        //验证参数并赋值
        RskCommRecVO entity = new RskCommRecVO();
        if(StringUtils.isNotEmpty(expressNo)){
            entity.setExpressNo(expressNo);
        }
        if(StringUtils.isNotEmpty(isRealAdress)){
            entity.setIsRealAdress(isRealAdress);
        }
        if(StringUtils.isNotEmpty(realAdress)){
            entity.setRealAdress(realAdress);
        }
        if(StringUtils.isNotEmpty(letterSendWay)){
            entity.setLetterSendWay(letterSendWay);
        }
        if(StringUtils.isNotEmpty(letterSendRes)){
            entity.setLetterSendRes(letterSendRes);
        }
        if (StringUtils.isNotEmpty(cstId)) {
            entity.setCstId(Long.valueOf(cstId));//客户ID
        }
        if(StringUtils.isNotEmpty(participant)){
            entity.setParticipant(participant);
        }
        /*if (StringUtils.isNotEmpty(collectTm)) {
            entity.setCollectTm(DateUtils.formatStringToDate(collectTm, DateUtils.YYYY_MM_DDHHMM));//催收时间
        }else{
        
        	entity.setCollectTm(DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DDHHMM));//催收时间
        }*/
        entity.setCollectTm(DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DDHHMM));//催收时间
        entity.setCstFeedbackCd(cstFeedbackCd);
        entity.setCompFeedbackCd(compFeedbackCd);
        entity.setCollectWayCd(collectWayCd);//催收方式RSK0001
        if (StringUtils.isNotEmpty(collectUsrId)) {
            entity.setCollectUsrId(Long.valueOf(collectUsrId));//催收员ID 
        }
        entity.setOvdReasonCd(ovdReasonCd);//欠款原因RSK0002
        entity.setLkMan(lkMan);//联系人
        entity.setLkPhone(lkPhone);//联系电话
        entity.setCollectRem(collectRem);//催收记录
        entity.setCollectRstCd(collectRstCd);//催收结果RSK0003
        /*if (StringUtils.isNotBlank(collectCost)) {
            entity.setCollectCost(DecimalUtils.convertYuanToFen(Double.valueOf(collectCost)).longValue());//催收成本
        }*/
        entity.setCstNm(cstNm);
        entity.setCollectUsrNm(collectUsrNm);
        //entity.setBuTypCd(buTypCd);
        entity.setBuTypCd("1");
       // entity.setBizNo(bizNo);

        Date tm = new Date();
        if (StringUtils.isNotBlank(id)) {
            entity.setId(Long.valueOf(id));
            entity.setMdfTm(tm);
            entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
        } else {
            entity.setCrtTm(tm);
            entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
        }
        if(StringUtils.isNotBlank(preLoanRskInfo)){
            entity.setPreLoanRskInfo(preLoanRskInfo);
        }
        if(StringUtils.isNotEmpty(lkAddr))//联系地址
            entity.setLkAddr(lkAddr);
        if(StringUtils.isNotEmpty(payWnCd))
            entity.setPayWnCd(payWnCd);
        if(StringUtils.isNotEmpty(invTypCd))
            entity.setInvTypCd(invTypCd);
        if(StringUtils.isNotEmpty(rlNm))
            entity.setRlNm(rlNm);
        if(StringUtils.isNotEmpty(rlMp))
            entity.setRlMp(rlMp);
        if(StringUtils.isNotEmpty(rlTypCd))
            entity.setRlTypCd(rlTypCd);
        if(StringUtils.isNotEmpty(letterTypCd))
            entity.setLetterTypCd(letterTypCd);
        if(StringUtils.isNotEmpty(visitRstCd))
            entity.setVisitRstCd(visitRstCd);
        if(StringUtils.isNotEmpty(isConnect))
            entity.setIsConnect(isConnect);
        if(StringUtils.isNotEmpty(cntStsCd))
            entity.setCntStsCd(cntStsCd);
        if(StringUtils.isNotEmpty(appoDt))
            entity.setAppoDt(DateUtils.formatStringToDate(appoDt,DateUtils.YYYY_MM_DD));
        if(StringUtils.isNotEmpty(lKTypCd))
            entity.setlKTypCd(lKTypCd);
        return entity;
    }

   /**
    * 到付件下载页面
    * @param request
    * @param response
    * @return
    * 
    */
   @RequestMapping(value = "/todownloadPage.do", method = {RequestMethod.GET})
   public ModelAndView todownloadPage(HttpServletRequest request, HttpServletResponse response) {
       String ids = request.getParameter("id");
       ModelAndView view = new ModelAndView("risk/rskCommRec/rskCommdownload");
       view.addObject("dataid", ids);
       
       return view;
   }

    /**
     * 修改页面 拼接数据字典
     * @param rskCommRecVO
     */
   private void setDictionaryForModify(RskCommRecVO rskCommRecVO){
       //催收方式
       List<KeyValueVO> collectWayCdList = this.rskCommRecNewService.getCollectWayCdList();
       if(CollectionUtils.isNotEmpty(collectWayCdList)){
           for(KeyValueVO kv : collectWayCdList){
               if(kv.getKey().equals(rskCommRecVO.getCollectWayCd())){
                   rskCommRecVO.setCollectWayCdNm(kv.getValue());
                   break;
               }
           }
       }
       //还款意愿
       List<KeyValueVO> payWnCdList = this.sysDictionaryApiService.getKvList(RiskConstant.CODE_PAY_WN_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
       if (CollectionUtils.isNotEmpty(payWnCdList)) {
           for(KeyValueVO kv : payWnCdList){
               if(kv.getKey().equals(rskCommRecVO.getPayWnCd())){
                   rskCommRecVO.setPayWnCd(kv.getValue());
                   break;
               }
           }
       }
       //逾期原因 KeyValueVO
      /* List<KeyValueVO> ovdReasonCdList = this.rskCommRecNewService.getOvdReasonCdList();
       if (CollectionUtils.isNotEmpty(ovdReasonCdList)) {

       }*/
       //逾期原因 SysDictionaryDTO
       Map<String, String> ovdReasonCdMap = sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), RiskConstant.CODE_OVD_REASON_CD);
       String ovdReasonCd = rskCommRecVO.getOvdReasonCd();
       if (CollectionUtils.isMapNotEmpty(ovdReasonCdMap) && StringUtils.isNotEmpty(ovdReasonCd)) {
           String[] split = ovdReasonCd.split(";");
           Iterator<String> iterator = Arrays.asList(split).iterator();
           String ovdRasonCdNm = "";
           while(iterator.hasNext()){
               String next = iterator.next();
               String s = ovdReasonCdMap.get(next);
               ovdRasonCdNm += s;
               if(iterator.hasNext()){
                   ovdRasonCdNm+=";";
               }
           }
           rskCommRecVO.setOvdReasonCdNm(ovdRasonCdNm);
       }
       //逾期催收结果
       List<KeyValueVO> collectRstCdList = this.rskCommRecNewService.getCollectRstCdList();
       if (CollectionUtils.isNotEmpty(collectRstCdList)) {
           for(KeyValueVO kv : collectRstCdList){
               if(kv.getKey().equals(rskCommRecVO.getCollectRstCd())){
                   rskCommRecVO.setCollectRstCdNm(kv.getValue());
                   break;
               }
           }
       }
       //还款方式
       List<KeyValueVO> payTypCdList = this.rskCommRecNewService.getPayTypCdList();
       if (CollectionUtils.isNotEmpty(payTypCdList)) {
           for(KeyValueVO kv : payTypCdList){
               if(kv.getKey().equals(rskCommRecVO.getPayTypCd())){
                   rskCommRecVO.setPayTypCd(kv.getValue());
                   break;
               }
           }
       }
       //接通情况
       List<KeyValueVO> cntStsCdList = sysDictionaryApiService.getKvList(RiskConstant.CODE_CNT_STS_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
       if (CollectionUtils.isNotEmpty(cntStsCdList)) {
           for(KeyValueVO kv : cntStsCdList){
               if(kv.getKey().equals(rskCommRecVO.getCntStsCd())){
                   rskCommRecVO.setCntStsCdNm(kv.getValue());
                   break;
               }
           }
       }

       //面谈人类型
       List<KeyValueVO> invTypCdList = sysDictionaryApiService.getKvList(RiskConstant.CODE_INV_TYP_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
       if (CollectionUtils.isNotEmpty(invTypCdList)) {
           for(KeyValueVO kv : invTypCdList){
               if(kv.getKey().equals(rskCommRecVO.getInvTypCd())){
                   rskCommRecVO.setInvTypCd(kv.getValue());
                   break;
               }
           }
       }
       //信函类型
       List<KeyValueVO> letterTypCdList = sysDictionaryApiService.getKvList(RiskConstant.CODE_LETTER_TYP_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
       if (CollectionUtils.isNotEmpty(letterTypCdList)) {
           for(KeyValueVO kv : letterTypCdList){
               if(kv.getKey().equals(rskCommRecVO.getLetterTypCd())){
                   rskCommRecVO.setLetterTypCdNm(kv.getValue());
                   break;
               }
           }
       }
       //外访结果
       List<KeyValueVO> visitRstCdList = sysDictionaryApiService.getKvList("RSK0036", CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
       if (CollectionUtils.isNotEmpty(visitRstCdList)) {
           for(KeyValueVO kv : visitRstCdList){
               if(kv.getKey().equals(rskCommRecVO.getVisitRstCd())){
                   rskCommRecVO.setVisitRstCdNm(kv.getValue());
                   break;
               }
           }
       }
       // 客户反馈受新型肺炎影响
       List<KeyValueVO> cstFeedbackCdList = sysDictionaryApiService.getKvList(RiskConstant.CST_FEEDBACK_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
       if (CollectionUtils.isNotEmpty(cstFeedbackCdList)) {
           for(KeyValueVO kv : cstFeedbackCdList){
               if(kv.getKey().equals(rskCommRecVO.getCstFeedbackCd())){
                   rskCommRecVO.setCstFeedbackCdNm(kv.getValue());
                   break;
               }
           }
       }
       // 公司审批受新型肺炎影响
       List<KeyValueVO> compFeedbackCdList = sysDictionaryApiService.getKvList(RiskConstant.COMP_FEEDBACK_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
       if (CollectionUtils.isNotEmpty(compFeedbackCdList)) {
           for(KeyValueVO kv : compFeedbackCdList){
               if(kv.getKey().equals(rskCommRecVO.getCompFeedbackCd())){
                   rskCommRecVO.setCompFeedbackCdNm(kv.getValue());
                   break;
               }
           }
       }
       // 信函发送结果
       String letterSendRes = rskCommRecVO.getLetterSendRes();
       if(StringUtils.isNotEmpty(letterSendRes)){
           Map<String, String> rsk0034 = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), "RSK0034");
           if(CollectionUtils.isMapNotEmpty(rsk0034)){
                rskCommRecVO.setLetterSendResNm(rsk0034.get(letterSendRes));
           }
       }
       // 信函发送方式
       String letterSendWay = rskCommRecVO.getLetterSendWay();
       if(StringUtils.isNotEmpty(letterSendWay)){
           Map<String, String> rsk0035 = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), "RSK0035");
           if(CollectionUtils.isMapNotEmpty(rsk0035)){
               rskCommRecVO.setLetterSendWayNm(rsk0035.get(letterSendWay));
           }
       }
       // 是否真实地址
       String isRealAdress = rskCommRecVO.getIsRealAdress();
       if(StringUtils.isNotEmpty(isRealAdress)){
           Map<String, String> rsk0015 = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), "RSK0015");
           if(CollectionUtils.isMapNotEmpty(rsk0015)){
               rskCommRecVO.setIsRealAdressNm(rsk0015.get(isRealAdress));
           }
       }
       String participant = rskCommRecVO.getParticipant();
       Map<String, String> rsk0037 = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), "RSK0037");
       if (CollectionUtils.isMapNotEmpty(rsk0037) && StringUtils.isNotEmpty(participant)) {
           String[] split = participant.split(";");
           Iterator<String> iterator = Arrays.asList(split).iterator();
           String participantNm = "";
           while(iterator.hasNext()){
               String next = iterator.next();
               String s = rsk0037.get(next);
               participantNm += s;
               if(iterator.hasNext()){
                   participantNm+=";";
               }
           }
           rskCommRecVO.setParticipantNm(participantNm);
       }
   }

    /**
     * 到新增联系人页面
     */
    @RequestMapping(value = "/toCustNpList.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toCustNpList(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toCustNpList", "请求参数:", JSONObject.toJSONString(request.getParameterNames()));
        ModelAndView mav = new ModelAndView("risknew/rskCommRec/custNpList");
        String cstId = request.getParameter("cstId");//客户ID
        String lkType = request.getParameter("lkType");//链接类型 1：新增  2：选择
        if(StringUtils.isNotEmpty(cstId)){
            /*CstBscInfoVO cstBscInfoVO = cstBscInfoService.selectById(Long.valueOf(cstId));
            if(cstBscInfoVO.getCstTypCd().equals("2")){
                //mav.setViewName("risk/rskCommRec/rskRentRecList");
            }*/
            mav.addObject("cstId", cstId);
            mav.addObject("lkType", lkType);
        }
        return mav;
    }

    private void uploadAttchment(HttpServletRequest request, DataResultVO result, Long id) {
        String attchmnt = request.getParameter("docArray");
        if(StringUtils.isNotEmpty(attchmnt)){
            //上传解析
            try{
               /* String cfgCd = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_CFGCD);
                String cfgDtlCd = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_CFGDTLCD);
                String tabNm = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_TABNM);
                String cfgOrgCd = PropertiesCacheUtils.getProperty(CustomerConstant.CST_BSCINFO_CFGORG);*/

                String cfgCd = "RSK002";
                String cfgDtlCd = "10";
                String tabNm = "RSK_COMM_REC";
                String cfgOrgCd = "0000";
                Boolean attchmntPass = this.sysUlFilesRecService.addAttchmnt(String.valueOf(id), attchmnt, cfgCd, cfgDtlCd, tabNm, "附件下载!", null, null, false, cfgOrgCd);
                if(null == attchmntPass || attchmntPass == false){
                    result.setInfo(result.getInfo()+"-附件上传失败!");
                }
            }catch(Exception e){
                BaseLogUtils.error(logger, "uploadAttchment", result.getInfo()+"-附件上传失败!", e);
                result.setInfo(result.getInfo()+"-附件上传失败!");
            }
        }
    }


}

